-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Add Health Checks #48
Conversation
@SebastianKuesters Do you have a better idea, to expose the Health Checks to the |
@robinmanuelthiel one suggestion as alternative would be the following which you call in the constructor: public Startup(IConfiguration configuration)
{
Configuration = configuration;
_options = new StartupOptions();
// Middleware
_options
.AddMiddleware<ApiExceptionFilter>();
// Add Swagger
_options
.AddOpenApi("v1")
.WithApiGroup("public", "Fancy API", "This is my fancy API.")
.WithSecurityScheme(SecuritySchemeDefaults.JwtBearer);
// Add Monitoring
_options
.AddMonitoring()
.WithMeter(Observability.Meter.Name)
.WithApplicationInsights(Configuration["AzureApplicationInsightsConnectionString"])
.WithPrometheus();
// OPTION A: Add Health Checks
_options.AddHealthChecks(healthCheckBuilder => {
healthCheckBuilder
.AddCheck("MyHealthCheck", () => HealthCheckResult.Healthy("Everything is fine.")
.AddCheck("MyOtherHealthCheck", MyHealthChecker) // Implement IHealthCheck
.AddSqlServer("<MY_CONNECTION_STRING>")
.AddDbContextCheck<SampleDbContext>();
});
// OPTION B: Configure Health Checks
_options.ConfigureHealthChecks(healthCheckBuilder => {
healthCheckBuilder
.AddCheck("MyHealthCheck", () => HealthCheckResult.Healthy("Everything is fine.")
.AddCheck("MyOtherHealthCheck", MyHealthChecker) // Implement IHealthCheck
.AddSqlServer("<MY_CONNECTION_STRING>")
.AddDbContextCheck<SampleDbContext>();
});
} So, as we are not able to access the I vote for Option B, as this is sth. that I know as .NET developer to have this |
I like these Options a lot. B) is also my favorite. Thanks! |
@SebastianKuesters can you pls review again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :)
Health Checks
The library automatically includes a health check endpoint at
/healthz
, which checks the basic health of the service.You can add additional health checks to the default setup.